<!--
	作者：956911785@qq.com
	时间：2019年8月15日11:41:28
	描述：学生原创搜索
-->
<template>
    <div style="width:100%;"> 
        <Tetable ref="tdtable" height="450" :columns="columns9" type="post" :paramiters="tj" :serverUrl="serverUrl"></Tetable>
        <setshzt ref="setshzt" v-on:setshzt="setshzt"></setshzt> 
        <look ref="look" :params="lookparam"></look>
    </div> 
</template>
<script>
	import EditDelLook from "./EditDelLook";
	import shzt from "./shzt";
	import setshzt from "./setshzt";
	import look from "./look";
    export default {
    	name: "xsycss",
    	props: {
    		tj:{
    			type: Object
    		},	
    	},
        data () {
            return {
            	serverUrl:"/host/readbook/xsyc/Search_bookxsyc.html",
                columns9: [
                    {
                        type: 'index',
                        width: 60,
                        title: '序号',
                        align: 'center'
                    },{
                        title: '学生姓名',
                        key: 'SNAME',
                        align: 'center', 
                    }, {
                        title: '年级',
                        key: 'NJ',
                        align: 'center', 
                    },  {
                        title: '班级',
                        key: 'BJ',
                        align: 'center', 
                    } ,{
                        title: '作品名称',
                        key: 'ZPMC',
                        align: 'center', 
                    },{
                        title: '审核状态',
                        key: 'BSTATET',
                        align: 'center', 
                        render: (h, params) => {
                        	
                        	return h(shzt, { 
                        		props: {
                                    bstate: params.row.BSTATE+"",
                                    bstatet: params.row.BSTATET,
                                },
	                        	on: { 
	                        		shenhe: () => {
										var pass=this.operatepermission();
										if(pass){
											this.ycid=params.row.YCID;
											this.$refs.setshzt.modal0=true;
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
	                        			
	                        		}
	                        	}
                        	})

                        }
                        
                    }, {
                        title: '操作',
                        key: 'action',
                        width: 120,
                        align: 'center',
                        render: (h, params) => {
                            return h(EditDelLook, {
                            	on: {
                                    //删除作品
                                    remove: () =>{
                                    	var pass=this.operatepermission();
										if(pass){
											const rows=params.row;
											this.remove(rows.YCID)
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    },
                                    
                                    //查看作品
                                    look: () =>{
                                    	const rows=params.row;
                                    	this.lookparam={
                                    		ycid:rows.YCID, 
											usid:rows.USID, 
											sname:rows.SNAME, 
											nj:rows.NJ, 
											bj:rows.BJ, 
											zpmc:rows.ZPMC, 
											content:rows.CONTENT, 
											bstate:rows.BSTATE,
											photos:rows.photos
                                    	}
										this.$refs.look.modal0=true;
                                    },
                                  
                                }
                            });
                        }
                    }
                ],
                lookparam:{},
                ycid:''
            }
        },
        computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		},
		methods: {
			//删除原创作品
			remove:function(ycid){
                this.$Modal.confirm({
                    title: '警告',
                    content: '请确定是否删除！！！',
                    onOk: () => {
                    	//执行删除代码
                    	this.$http.get("/host/readbook/xsyc/del_bookxsyc.html?ycid="+ycid)
						.then(datas => {
							if(datas.result){
								//删除成功 刷新页面
								this.$Message.info('删除成功');
								this.$refs.tdtable.load();
							}else{
								//删除成功 刷新页面
								this.$Message.info(datas.msg);
								this.$refs.tdtable.load();
							}
							
						});
                    }
                });
			},
			
			
			load(){
				this.$refs.tdtable.load();
			},


			setshzt(sh){
				const params={
					sh:sh,
					ycid:this.ycid
				};
				this.$http.post("/host/readbook/xsyc/setshzt_xsyc.html",params)
				.then(result => {
					this.$Message.info('审核成功');
					this.$refs.setshzt.modal0=false;
					this.load();
				});
			},
			
			
			operatepermission(){
				if(this.user.uname=='admin'){
					return true;
				}
				if(this.user.permission && this.user.permission.indexOf("2")>-1){
					return true;
				}else if(this.user.permission && this.user.permission.indexOf("1")>-1){
					return true;
				}else if(this.user.permission && this.user.permission.indexOf("4")>-1){
					return true;
				}else{
					return false;
				}
			},
	    },
		mounted() {
		},
		watch:{
		},
		components: {
			EditDelLook,
			shzt,
			setshzt,
			look
		}
    }
</script>


<style scoped="scoped">
	
	.ivu-table-wrapper {
		border:none;
	}
	
	.toolstipdiv{
		width: '100%';
		overflow: 'hidden';
		textOverflow: 'ellipsis';
		whiteSpace: 'normal';
		wordBreak: 'break-all';
		color:'#fff';
		text-align: center;
	}
	.toolstipdiv:hover{
		background:rgb(63, 193, 201);
	}
	
	.ivu-tooltip-rel label:hover{
		color:#0023FB;
	}
	
	.tablediv{
		height: '40px';
		overflow:'hidden';
		line-height: '40px';
	}
</style>



